package com.palrevo.utils;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import com.palrevo.common.Constants;

/**
 * This class have the logging operations.
 *
 * @author AAsha
 *
 */
public class Log {
	
	static{
		configureLogging();
	}

    /**
     *
     */
    public static void configureLogging() {
        BasicConfigurator.resetConfiguration();
        PropertyConfigurator.configure(Log.class.getClassLoader().getResource(Constants.LOG_PROPERTIES_FILE));
    }

    /**
     *
     * @param source
     * @param msg
     */
    public static void debug(Object source, String msg) {
        Logger logger = Logger.getLogger(source.getClass());
        logger.debug(msg);
    }

    /**
     *
     *
     * @param source
     * @param msg
     * @param throwable
     */
    public static void debug(Object source, String msg, Throwable throwable) {
        Logger logger = Logger.getLogger(source.getClass());
        logger.debug(msg, throwable);
    }

    /**
     *
     * @param source
     * @param msg
     */
    public static void info(Object source, String msg) {
        Logger logger = Logger.getLogger(source.getClass());
        logger.info(msg);
    }

    /**
     *
     * @param source
     * @param msg
     * @param throwable
     */
    public static void info(Object source, String msg, Throwable throwable) {
        Logger logger = Logger.getLogger(source.getClass());
        logger.info(msg, throwable);
    }

    /**
     *
     * @param source
     * @param msg
     */
    public static void error(Object source, String msg) {
        Logger logger = Logger.getLogger(source.getClass());
        logger.error(msg);
    }

    /**
     *
     * @param source
     * @param msg
     * @param throwable
     */
    public static void error(Object source, String msg, Throwable throwable) {
        Logger logger = Logger.getLogger(source.getClass());
        logger.error(msg, throwable);
    }

    /**
     *
     * @param source
     * @param msg
     */
    public static void warn(Object source, String msg) {
        Logger logger = Logger.getLogger(source.getClass());
        logger.warn(msg);
    }

    /**
     *
     * @param source
     * @param msg
     * @param throwable
     */
    public static void warn(Object source, String msg, Throwable throwable) {
        Logger logger = Logger.getLogger(source.getClass());
        logger.warn(msg, throwable);
    }

    /**
     *
     * @param source
     * @param msg
     */
    public static void fatal(Object source, String msg) {
        Logger logger = Logger.getLogger(source.getClass());
        logger.fatal(msg);
    }

    /**
     *
     * @param source
     * @param msg
     * @param throwable
     */
    public static void fatal(Object source, String msg, Throwable throwable) {
        Logger logger = Logger.getLogger(source.getClass());
        logger.fatal(msg, throwable);
    }
}
